package day0614;

import java.util.Arrays;

public class Test2 {
    public static void main(String[] args) {
        int[] arr={3,44,38,5,1};

/*      int t=arr[1];
        int i=0;
        for(; i>=0 &&t<arr[i]; i--){
               arr[i+1]=arr[i];
        }
        arr[i+1]=t;
        System.out.println(Arrays.toString(arr));






        t=arr[2];
        i=1;
        for(; i>=0&&t<arr[i]; i--){
                arr[i+1]=arr[i];
        }
        arr[i+1]=t;
        System.out.println(Arrays.toString(arr));





        t=arr[3];//[3, 38, 44, 5, 1]
        i=2;
        for(; i>=0&&t<arr[i]; i--){
            arr[i+1]=arr[i];
        }
        arr[i+1]=t;
        System.out.println(Arrays.toString(arr));//结果：[3,5, 38, 44, 1]








        t=arr[4];//[3,5, 38, 44, 1]
        i=3;
        for(  ;i>=0&&t<arr[i];  i--){
            arr[i+1]=arr[i];
        }
        arr[i+1]=t;
        System.out.println(Arrays.toString(arr));*/









        for(int j=1; j<arr.length; j++){
            int t=arr[j];
            int i=j-1;
            for(; i>=0 &&t<arr[i]; i--){
                arr[i+1]=arr[i];
            }
            arr[i+1]=t;
        }
        System.out.println(Arrays.toString(arr));
















    }
}
